#include "dialog_startup.h"
#include "font_dotumchehei.h"
#include "bmp_backgrounds.h"


StartupDialog::StartupDialog(HWND parent) :Dialog(parent)
{
    setSize(212,64);
    name =(char*)"StartupDialog";

    pBarProgress =new Bar(this);
    pLableStatus =new Lable(this, (char *)"Starting ...");
    //pLableLogo =new Lable(this, " Free TX Group"); 

    pBarProgress->setMinValue(0);
    pBarProgress->setMaxValue(100);
    pBarProgress->setStyle(TWIND_HBAR);
    pBarProgress->setValue(0);

    //pLableLogo->setFont(font_DOTUMCHEHEI);
    pLableStatus->setFont(font_STANDARD);

    //pLableLogo->setPosition(5, 5);
    pBarProgress->setPosition(5, 16); pBarProgress->setSize(202,16);
    pLableStatus->setPosition(5, 45);
}

StartupDialog::~StartupDialog()
{
    delete pBarProgress;
    delete pLableStatus;
    //delete pLableLogo;
}

void StartupDialog::draw(Rect *r)
{
    //draw this window

    //fill rect with a bitmap
    short x,y;
    for( y=rect.y0; y<rect.y1; y+=bitmapFreeTx.h)
    {
        for(x=rect.x0; x<rect.x1; x+=bitmapFreeTx.w)
        {
            pDC->drawBmp(x, y, x+bitmapFreeTx.w, y+bitmapFreeTx.h, bitmapFreeTx.data);
        }
    }

    pDC->dirty(max(r->x0,rect.x0), max(r->y0,rect.y0), min(r->x1,rect.x1), min(r->y1,rect.y1));
    Widget::draw(r);    
}

/*
void StartupDialog::setLogoText(char *s)
{
    pLableLogo->setText(s);
}
*/
void StartupDialog::setStatusText(char *s)
{
    pLableStatus->setText(s);
}

void StartupDialog::setStep(int step)
{
    if(step<=100)
    {
        pBarProgress->setValue(step);
    }
}
